﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using EMC;
using System.Reflection;

namespace TestEMC
{
    [TestClass]
    public class TestUserManagement
    {
        static string dbConfigFile = Path.GetDirectoryName(Assembly.GetAssembly(typeof(TestUserManagement)).CodeBase) + @"/db_settings.xml";
        static databaseConfiguration config = new databaseConfiguration(dbConfigFile);
        UserManagement userman = new UserManagement(config);

        [TestMethod]
        public void TestuserAdd()
        {
            Assert.AreEqual(userman.adduser("billfred", "bill", "fred", "pass", "0401 636 230","bob@bill.com.au"),true);
        }
        
        [TestMethod]
        public void TestuserEdit()
        {
            Assert.AreEqual(userman.editUser("billfred", "bob", "bill", null, "0449 034 324", "bill@google.com"), true);
        }

        [TestMethod]
        public void TesteserExists()
        {
            Assert.AreEqual(userman.userExists("billfred"), true);
        }

        [TestMethod]
        public void TestuserAuthenticate()
        {
            Assert.AreEqual(userman.authenticateUser("billfred", userman.GetUserPassword("billfred")), true);
        }

        [TestMethod]
        public void TestuserDel()
        {
            Assert.AreEqual(userman.delUser("billfred"), true);
        }
    }
}
